package com.thread.plbc;

import java.util.concurrent.ArrayBlockingQueue;

/**
 * @author げっしょく
 * @date 2021/8/6
 */
public class ThreadD8Foodie extends Thread {
    private ArrayBlockingQueue<String> list;

    public ThreadD8Foodie(ArrayBlockingQueue<String> list) {
        this.list = list;
    }

    @Override
    public void run() {
        while (true) {
            try {
                String take = list.take();
                System.out.println("舔美者吃了" + take);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

class T8Coolde extends Thread {
    private ArrayBlockingQueue<String> list;

    public T8Coolde(ArrayBlockingQueue<String> list) {
        this.list = list;
    }

    @Override
    public void run() {
        while (true) {
            try {
                list.put("美国空气");
                System.out.println("生产者生产了美国空气");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

